<%@ Page Title="View Product" Language="C#" MasterPageFile="~/Admin/AdminDefault.master" AutoEventWireup="true" CodeFile="ViewProduct.aspx.cs" Inherits="Admin_Product_ViewProduct" %>

<%@ Register Assembly="AjaxControlToolkit.WCSFExtensions" Namespace="AjaxControlToolkit.WCSFExtensions"
    TagPrefix="cc2" %>

<%@ Register assembly="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet" namespace="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet" tagprefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <br />
    <asp:LinkButton ID="LinkButton5" runat="server" PostBackUrl="~/Admin/Product/ManageProducts.aspx">&lt;&lt;Return Back to Page</asp:LinkButton>
    <br />
        
    <h2>Product Details</h2>
    
    <asp:Label CssClass="alarm" ID="lblResult" EnableViewState ="false" Text="" runat="server" Visible="false" />
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
        ValidationGroup="ProductValidation" HeaderText="Errors:" 
        EnableViewState="False" />
    
    <br />
    <asp:DetailsView ID="dvProduct" runat="server" Height="50px" Width="450px" 
    DataSourceID="ProductDS" AutoGenerateRows="False" DataKeyNames="ProductId" 
        EnableViewState="False" oniteminserted="dvProduct_ItemInserted">
        <Fields>
            <asp:BoundField DataField="ProductId" HeaderText="ProductId" 
                SortExpression="ProductId" Visible="False" />
            <asp:TemplateField HeaderText="Product Type" SortExpression="ProductTypeId">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlProductType" runat="server" 
                        DataSourceID="ProductTypeDS" DataTextField="Name" 
                        DataValueField="ProductTypeId" SelectedValue='<%# Bind("ProductTypeId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddlProductType" runat="server" 
                        DataSourceID="ProductTypeDS" DataTextField="Name" 
                        DataValueField="ProductTypeId" SelectedValue='<%# Bind("ProductTypeId") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductType.Name") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Name" SortExpression="Name">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                    <cc1:PropertyProxyValidator ID="PropertyProxyValidator1" ControlToValidate="TextBox2"
                     ValidationGroup="ProductValidation" PropertyName="Name" RulesetName="DefaultRuleSet"
                     SourceTypeName="Ample.Model.Product, AmpleDAL" SpecificationSource="Configuration" 
                     runat="server" >*</cc1:PropertyProxyValidator>
                     
                     <cc2:ServerSideValidationExtender
                        ID="ServerSideValidationExtender2" 
                        TargetControlID="PropertyProxyValidator1" ValidateEmptyText="false"
                        runat="server">
                    </cc2:ServerSideValidationExtender>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Price" SortExpression="Price">
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("Price", "{0:c}") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Price", "{0:c}") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Package" SortExpression="Package" ItemStyle-Width="75%">
                <EditItemTemplate>
                    <asp:TextBox Width="98%" ID="TextBox10" runat="server" Text='<%# Bind("Package") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox Width="98%" ID="TextBox10" runat="server" Text='<%# Bind("Package") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label10" runat="server" Text='<%# Bind("Package") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle Width="75%"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Description" SortExpression="Description" ItemStyle-Width="75%">
                <EditItemTemplate>
                    <asp:TextBox Width="98%" TextMode="MultiLine" ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox Width="98%" TextMode="MultiLine" ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle Width="75%"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Update"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="True" 
                        CommandName="Insert" Text="Insert" ValidationGroup="ProductValidation"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Cancel" PostBackUrl="~/Admin/Product/ManageProducts.aspx"></asp:LinkButton>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Edit"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Fields>
    </asp:DetailsView>
    <asp:ObjectDataSource ID="ProductTypeDS" runat="server" 
            OldValuesParameterFormatString="{0}" SelectMethod="GetProductTypes" 
            TypeName="Ample.BLL.ProductTypeBO" 
        DataObjectTypeName="Ample.Model.ProductType" EnableViewState="false" 
        ></asp:ObjectDataSource>    
    <asp:ObjectDataSource ID="ProductDS" runat="server" 
        DataObjectTypeName="Ample.Model.Product" InsertMethod="InsertProduct" 
        SelectMethod="GetProductById" TypeName="Ample.BLL.ProductBO" 
        UpdateMethod="UpdateProduct"
        DeleteMethod="DeleteProduct" oninserted="ProductDS_Inserted" 
        onselecting="ProductDS_Selecting" EnableViewState="false" OnInserting="ProductDS_Inserting">
    <SelectParameters>
        <asp:QueryStringParameter Name="prodId" QueryStringField="ID" Type="Int32" />
    </SelectParameters>
    </asp:ObjectDataSource>
    
</asp:Content>

